<?php
function renderForm()
{
?>
<!----------HTML CODES----------------------------------------------------------------------------------->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta name="Description" content="Clinic Management System" />
	<link rel="stylesheet" href="../includes/Style.css" type="text/css" />
	<link rel="stylesheet" href="../includes/jquery-ui.css" />
	<script src="../includes/jquery-1.8.3.js"></script>
	<script src="../includes/jquery-ui.js"></script>
	<title>OPTICSoft</title>
	<script type="text/javascript">
	
        $(document).ready(function() {
         $( "#supplier" ).autocomplete({
            source: "getSuppliers.php",
         });       

        });
        
        function addRow(tableID) 
        {
	      var table = document.getElementById(tableID);
              var rowCount = table.rows.length;
	      var row = table.insertRow(rowCount);

	      var cell1 = row.insertCell(0);
	      var element1 = document.createElement("input");
	      element1.type = "checkbox";
	      element1.name="chkbox[]";
	      cell1.appendChild(element1);

	      var cell2 = row.insertCell(1);
	      var element2 = document.createElement("input");
	      element2.type = "text";
	      element2.name = "txtbox[]";
	      cell2.appendChild(element2);
	      
	      var cell3 = row.insertCell(2);
	      var element3 = document.createElement("input");
	      element3.type = "text";
	      element3.name = "txtbox[]";
	      cell3.appendChild(element3);
	      
	      var cell4 = row.insertCell(3);
	      var element4 = document.createElement("input");
	      element4.type = "text";
	      element4.name = "txtbox[]";
	      cell4.appendChild(element4);
	}

	function deleteRow(tableID) 
	{
		try {
			var table = document.getElementById(tableID);
			var rowCount = table.rows.length;

			for(var i=0; i<rowCount; i++) {
				var row = table.rows[i];
				var chkbox = row.cells[0].childNodes[0];
				if(null != chkbox && true == chkbox.checked) {
					table.deleteRow(i);
					rowCount--;
					i--;
				}
			}
		}
		catch(e) 
		{	alert(e); 	}
	}
        </script>
</head>
<body>
<?php include('../includes/header.php');?>
<div id="content-wrap"><div id="content">

<?php displayMessage(); ?>
<?php include('sidebar.php');?>

<div id="main">	<div class="post">	
	<h1>Goods Receipt</h1>				
	
	 <form name="main" action="" class="searchform" method="POST">
  	 <table>
  	  <tr>
  		<td align="right">Posting Date</td>
  		<td align="left"><input type="text" name="posDate" value="<?php echo date("Y/m/d"); ?> " /></td>
  		<td align="right"> 		
	 	  <input name="submit" class="button" value="Add" type="submit" />
	 	</td>
  	  </tr>
  	  <tr>
  		<td align="right">Items Received</td>
  		<td align="left"><input type="text" name="itemsRec" /></td>
  	 </tr>
  	 <tr>
  		<td align="right">Supplier</td>
  		<td align="left"><input type="text" id="supplier" name="supplier" onKeyUp="loadSuppliers()"/>
  		</td>
  	 </tr>
  	 <tr>
  		<td align="right">Comment</td>
  		<td align="left"><textarea name="comments"  value=""></textarea>  	
  		</td>
  	  </tr>
  	 </table> 
  	 
  	 
  	 <p>
  	    <INPUT type="button" class="button" value="Add" onclick="addRow('dataTable')" margin="500px"/>
	    <INPUT type="button" class="button" value="Delete" onclick="deleteRow('dataTable')" /
	 </p>
	 <table id="dataTable" width="350px" border="1">
		<tr>
			<th class="first"></th>
			<th> Item Code </th>
			<th> Description </th>
			<th> Quantity </th>
		</tr>
	 </table>
  	 </form>
  	 
</div></div></div></div>
</body>
</html>
<!----------------------------------------------------------------------------------------------------------->
<?php
}
  //include statement
  require("goodsreceipt.inc");
  $gr = new GoodsReceipt();
  global $error;
  
  renderForm();
  //FUNCTIONS
  function CheckInput()
  {
     if ($_POST['name'] == '')
     	return false;
     return true;
  }
  function displayMessage()
  {
     if (isset($error) && $error != '')
      echo '<div id="notification">'.$error.'</div>';
     if(isset($_COOKIE['message']))
       echo '<div id="notification">'.$_COOKIE["message"].'</div>';
  }
?>
<!----------------------------------------------------------------------------------------------------------->

